/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-07-11 08:26:06
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Api.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { DelDataButton, CommonButton, ExamineButton, OpenSelection } from '../Common/options'

import { SecurityProblemTypeTree } from '../Common/Conversion'

export const AnonymousSecurity = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const optionsData = await SecurityProblemTypeTree()
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'eventTime@desc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenSelection
                OptionsEvent={OptionsEvent}
                title="批量删除"
                type="primary"
                danger
                data={{
                    type: 'SelectionDelete',
                    url: 'posBatchRemoveAnonymousSecurities',
                }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, rules: true },
            {
                dataIndex: 'content',
                title: '内容',
                valueType: 'input',
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'eventTime',
                title: '事件时间',
                valueType: 'Date',
                showTime: true,
                ellipsis: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'tel',
                title: '手机号',
                valueType: 'inputNumber',
                ellipsis: true,
                width: 200,
            },
            {
                dataIndex: 'approvalStatus',
                title: '审核状态',
                valueType: 'select',
                valueEnum: {
                    0: '未审核',
                    1: '审核通过',
                    2: '审核未通过',
                },
                ellipsis: true,
                width: 200,
            },
            commonTableList.StartTime,
            commonTableList.EndTime,

            commonTableList.remark,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, approvalStatus } = record
                    return [
                        <CommonButton
                            key="submit"
                            OptionsEvent={OptionsEvent}
                            title="图片列表"
                            data={{ type: 'AnonymousSecurityAnnex', record, width: 1000 }}
                        />,
                        approvalStatus === 1 ? (
                            <CommonButton
                                key="add"
                                OptionsEvent={OptionsEvent}
                                title="添加巡检"
                                data={{ type: 'AddFromTemp', record, width: 1000, optionsData, ClientData }}
                            />
                        ) : (
                            <ExamineButton
                                key="one"
                                title="审核"
                                data={{
                                    actionRef,
                                    OptionsEvent,
                                    url: 'posAnonymousSecurityApproval',
                                    smallTitle: '审核随手拍',
                                }}
                                options={[
                                    { title: '通过', type: 'primary', emit: { path: [uuid, 1] } },
                                    { title: '不通过', type: 'primary', danger: true, emit: { path: [uuid, 2] } },
                                ]}
                            />
                        ),

                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
